package com.example.design.command;

public class Client {
	
	public static void main(String[] args) {
		FBSettingWindow window = new FBSettingWindow("功能设置键");
		Command c1 = new HelpCommand("");
		Command c2 = new MinimizeCommand("");
		
		FunctionButton fb1,fb2;  
        fb1 = new FunctionButton("功能键1");  
        fb2 = new FunctionButton("功能键2"); 
        
        window.addFunctionButton(fb2);
        window.addFunctionButton(fb1);
        fb1.setCommand(c1);
        fb2.setCommand(c2);
        window.display();
        
        fb1.onClick();
        fb2.onClick();
		//c1.execute();
		//c2.execute();
        AbstractCommand c3 = new ConcreteCommand();
        
        CalculatorForm form = new CalculatorForm(c3);
        form.compute(10);
        form.compute(2);
        form.undo();
        form.undo();
        
        /////////////////////////////////////////////
        ConfigSettingWindow csw = new ConfigSettingWindow(); //定义请求发送者  
        Command command; //定义命令对象  
        ConfigOperator co = new ConfigOperator(); //定义请求接收者  
          
        //四次对配置文件的更改  
        command = new InsertCommand("增加");  
        command.setConfigOperator(co);  
        csw.setCommand(command);  
        csw.call("网站首页");  
          
        command = new InsertCommand("增加");  
        command.setConfigOperator(co);  
        csw.setCommand(command);  
        csw.call("端口号");  
          
        command = new ModifyCommand("修改");  
        command.setConfigOperator(co);  
        csw.setCommand(command);  
        csw.call("网站首页");  
          
        command = new ModifyCommand("修改");  
        command.setConfigOperator(co);  
        csw.setCommand(command);          
        csw.call("端口号");  
          
        System.out.println("----------------------------");  
        System.out.println("保存配置");  
        csw.save();  
              
        System.out.println("----------------------------");   
        System.out.println("恢复配置");  
        System.out.println("----------------------------");   
        csw.recover();    
	}

}
